import type { RouteRecordRaw } from "vue-router"; //引入vue-router类型

//静态路由
const staticRoutes: Array<RouteRecordRaw> = [
  {
    // 首页 包含管理员登录与用户中心登录
    path: "/",
    name: "Home",
    component: () => import("@/views/common/login.vue"),
    meta: {
      title: "首页",
      authorization: true,
    },
  },
  {
    // 后台找不到页面了-可能是路由未加载上
    path: "/admin:pathMatch(.*)*",
    redirect: (to) => {
      return {
        name: "adminMainLoading",
        query: { url: to.path, query: JSON.stringify(to.query) },
      };
    },
  },
  {
    // 会员中心找不到页面了
    path: "/user:pathMatch(.*)*",
    redirect: (to) => {
      return {
        name: "userMainLoading",
        query: { url: to.path, query: JSON.stringify(to.query) },
      };
    },
  },
];

// 用户中心静态路由
const userCenterBaseRoute: RouteRecordRaw = {
  path: "/user",
  name: "user",
  component: () => import("@/layouts/frontend/user.vue"),
  redirect: "/user/loading",
  meta: {
    title: "用户中心",
    menu_type: "tab",
    authorization: true,
  },
  children: [
    {
      path: "/user/loading",
      name: "userMainLoading",
      component: () => import("@/layouts/common/loading.vue"),
      meta: {
        title: "Loading",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/user/account/profile",
      name: "accountProfile",
      component: () => import("@/views/frontend/user/profile.vue"),
      meta: {
        title: "个人资料",
        menu_type: "menu",
        authorization: true,
        type: "tab",
      },
    },
    {
      path: "/user/account/changePassword",
      name: "accountChangePassword",
      component: () => import("@/views/frontend/user/changePassword.vue"),
      meta: {
        title: "修改密码",
        menu_type: "menu",
        authorization: true,
        type: "tab",
      },
    },
  ],
};
//后台管理系统静态路由
const adminBaseRoute: RouteRecordRaw = {
  path: "/admin",
  name: "admin",
  component: () => import("@/layouts/backend/index.vue"),
  redirect: "/admin/loading",
  meta: {
    title: "后台管理",
    authorization: true,
    // addtab: true,
  },
  children: [
    {
      path: "/admin/loading",
      name: "adminMainLoading",
      component: () => import("@/layouts/common/loading.vue"),
      meta: {
        title: "Loading",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/BusinessM/detail",
      name: "adminBusinessMDetail",
      component: () =>
        import("@/views/backend/BusinessM/info/components/detail.vue"),
      meta: {
        title: "企业详情页",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/BusinessM/ledgerDetail",
      name: "ledgerDetail",
      component: () =>
        import("@/views/backend/BusinessM/info/components/ledgerDetail.vue"),
      meta: {
        title: "企业台账详情页",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/DeviceM/accessDetail",
      name: "adminDeviceMaccessDetail",
      component: () =>
        import("@/views/backend/DeviceM/access/components/detail.vue"),
      meta: {
        title: "接入点详情页",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/system/file",
      name: "adminSystemledFile",
      component: () =>
        import("@/views/backend/BusinessM/ledger/components/detail.vue"),
      meta: {
        title: "台账详情页",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/WorkOrder/detail",
      name: "adminWorkOrderDetail",
      component: () =>
        import(
          "@/views/backend/WorkOrder/maintenanceOrder/components/detail.vue"
        ),
      meta: {
        title: "工单详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/task/detail",
      name: "adminTaskDetail",
      component: () =>
        import("@/views/backend/LineCruise/task/components/detail.vue"),
      meta: {
        title: "巡检任务详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/ProductionPlan/detail",
      name: "adminProductionPlanDetail",
      component: () =>
        import(
          "@/views/backend/ProductionPlan/planManager/components/detail.vue"
        ),
      meta: {
        title: "生产计划详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/ProductionWorkOrder/detail",
      name: "adminProductionOrderDetail",
      component: () =>
        import(
          "@/views/backend/ProductionPlan/workOrder/components/detail.vue"
        ),
      meta: {
        title: "工单详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/AssetCabinet/detail",
      name: "adminAssetCabinetDetail",
      component: () =>
        import("@/views/backend/Assets/cabinet/components/detail.vue"),
      meta: {
        title: "机柜详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/5Gsmall/detail",
      name: "admin5GsmallDetail",
      component: () => import("@/views/backend/5Gsmall/components/detail.vue"),
      meta: {
        title: "机柜大屏详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/DataMRealTime/detail",
      name: "adminDataMRealTimeDetail",
      component: () =>
        import("@/views/backend/DataM/RealTime/components/detail.vue"),
      meta: {
        title: "实时数据详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/DataMHistoryTime/detail",
      name: "adminDataMHistoryTimeDetail",
      component: () =>
        import("@/views/backend/DataM/HistoryTime/components/detail.vue"),
      meta: {
        title: "实时数据详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/WarningRule/detail",
      name: "adminWarningRuleDetail",
      component: () =>
        import("@/views/backend/Warning/rule/components/detail.vue"),
      meta: {
        title: "策略详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/BoardProcessPull/detail",
      name: "adminBoardProcessPullDetail",
      component: () =>
        import("@/views/backend/Board/processPull/components/detail.vue"),
      meta: {
        title: "工序看板料号详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/BoardMasterPlan/detail",
      name: "adminBoardMasterPlanDetail",
      component: () =>
        import("@/views/backend/Board/MasterPlan/components/detail.vue"),
      meta: {
        title: "主计划看板料号详情",
        menu_type: "tab",
        authorization: true,
      },
    },
    {
      path: "/admin/BoardMasterPlan/detail",
      name: "adminBoardMasterPlanDetail",
      component: () =>
        import("@/views/backend/Board/MasterPlan/components/detail.vue"),
      meta: {
        title: "主计划看板料号详情",
        menu_type: "tab",
        authorization: true,
      },
    },
  ],
};
// 用户中心静态路由加入静态路由表中
staticRoutes.push(userCenterBaseRoute);
staticRoutes.push(adminBaseRoute);

export { staticRoutes, userCenterBaseRoute, adminBaseRoute };
